/*
    This file is part of Raptor.

    Raptor is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Raptor is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Raptor.  If not, see <http://www.gnu.org/licenses/>.

 */

#ifndef CAPTCHAWIZARD_H
#define CAPTCHAWIZARD_H

#include <QWizard>

#include "include/xmlUrlContainer.h"

class QLabel;
class QTextEdit;
class QLineEdit;
class QListWidget;
class QTreeView;
class QProgressBar;
class QStandardItemModel;
//class QComboBox;

class linksPage;
class folderPage;

class captchaWizard : public QWizard
{
	Q_OBJECT

	public:

                enum { Page_Captcha, Page_Links, Page_Folder };

		QStringList urlList;
		QString captcha;
		QString captchaInput;
                QString folder;

                captchaWizard(QPointer<xmlUrlContainer> urlC, QUrl url, QString _folder, QWidget *parent = 0);
		bool validateCurrentPage();

	private:
		QPointer<linksPage> myLinksPage;
                QPointer<folderPage> myFolderPage;

};

class captchaPage : public QWizardPage
{
	Q_OBJECT

	public:
		captchaPage(QPointer<xmlUrlContainer> urlContainer, QUrl url, QPointer<captchaWizard> parent);
		int nextId() const;

	private:
		QPointer<xmlUrlContainer> urlC;
		QPointer<captchaWizard> cWizard;

		QPointer<QLabel> topLabel;
		QPointer<QLineEdit> lineEditCaptcha;
		QPointer<QLabel> captchaLabel;

	private slots:
		void slot_urlC_captcha(const QString &captcha);
};

class linksPage : public QWizardPage
{
	Q_OBJECT

	public:
		linksPage(QPointer<xmlUrlContainer> urlContainer, QPointer<captchaWizard> parent);
		void initializePage();
		int nextId() const;

		const QPointer<QStandardItemModel> model() const {return modelFiles;}

	private:
		QPointer<xmlUrlContainer> urlC;
		QPointer<captchaWizard> cWizard;

		QPointer<QLabel> topLabel;

                QPointer<QPushButton> checkPushButton;

		QPointer<QTreeView> treeView;
		QPointer<QStandardItemModel> modelFiles;

		QPointer<QProgressBar> progressBar;

	private slots:
		void slot_urlC_finished(const QStringList &urlList, const bool &error);
		void slot_urlC_captcha(const QString &captcha);
		void slot_urlC_progressChanged(const int &progress);

                void slot_checkPushButton_clicked();
};


class folderPage : public QWizardPage
{
    Q_OBJECT

    public:
        folderPage(QPointer<captchaWizard> parent);
        int nextId() const;

        const QPointer<QLineEdit> folder() const {return folderLineEdit;}

    private:
        QPointer<captchaWizard> cWizard;

        QPointer<QLabel> topLabel;
        QPointer<QLineEdit> folderLineEdit;

    private slots:
};

#endif
